home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 19.zip / BS1 part 19 / power Window v2.5.adf / TB / PW2TB.header < prev    next >
Text File  |  1988-09-15  |  5KB  |  99 lines

  1. ! **************************************************************************
  2. ! *  THIS CODE IS IN NO WAY COPYRIGHT BY INOVATRONICS, INC.  IN FACT, YOU  *
  3. ! *  CAN DO ANYTHING WITH IT THAT YOU WANT TO DO.  JUST REMEMBER,          *
  4. ! *  INOVATRONICS, INC. WILL BEAR ABSOLUTELY NO RESPONSIBILITY FOR THE USE,*
  5. ! *  MISUSE, INABILITY TO USE OR INABLITY TO UNDERSTAND ANY OR ALL PARTS OF*
  6. ! *  THIS CODE.  ENJOY IT IN GOOD HEALTH.                                  *
  7. ! **************************************************************************
  8. ! **************************************************************************
  9. ! *  THE PURPOSE OF THE CODE IS TO LET YOU SEE WHAT YOUR PowerWindows2     *
  10. ! *  GENERATED SOURCE CODE WILL LOOK LIKE IN A PROGRAM.  IT DEFAULTS TO    *
  11. ! *  TERMINATING WHEN THE CLOSE GADGET IS HIT, BUT IF YOU LOOK BELOW       *
  12. ! *  YOU'LL SEE HOW TO MAKE IT TERMINATE ON ANY EVENT AT ALL.              *
  13. ! *  PLEASE NOTE: IT IS DESIGNED FOR ONLY 1 WINDOW.  IT WILL LOAD A SCREEN *
  14. ! *  AND A PALETTE IF THEY ARE PRESENT, BUT ONLY WINDOW NUMBER 1 AND ITS   *
  15. ! *  PROGENY.                                                              *
  16. ! **************************************************************************
  17.  
  18. LIBRARY "pw2tb:PW2TBsupport*", "toolkit:libs/intuition*", "toolkit:libs/graphics*", "toolkit:libs/exec*", "toolkit:libs/amiga*"
  19.  
  20. DECLARE DEF ALLOCREMEMBER, PeekW, PeekL
  21. DECLARE DEF MakeNewScreenStructure, MakeNewWindowStructure
  22. DECLARE DEF MakeITextStructure, MakeMenuStructure
  23. DECLARE DEF MakeMenuItemStructure, MakeGadgetStructure
  24. DECLARE DEF MakeRequesterStructure, MakeBoolInfoStructure
  25. DECLARE DEF MakeStringInfoStructure, MakePropInfoStructure
  26. DECLARE DEF MakeImageStructure, MakeTextAttrStructure
  27. DECLARE DEF MakeBorderStructure, MakeNullTString
  28. DECLARE DEF OpenScreen, FreeRemember, OpenWindow, ReplyMsg
  29. DECLARE DEF SetMenuStrip, CloseWindow, CloseScreen
  30. DECLARE DEF ClearMenuStrip, WaitPort, ItemAddress, GetMsg
  31. DECLARE DEF DrawBorder, DrawImage, PrintIText, LoadRGB4
  32.  
  33.         CALL example  !  allocate all the structures
  34.  
  35.         IF PW2EnoughMemory=1 THEN  !  proceed only if allocation succeeded
  36.  
  37.                 IF NewScreenStructure<>0 THEN  !  open the screen if there
  38.                         LET Screen = OpenScreen(NewScreenStructure)
  39.                         IF Screen=0 THEN STOP
  40.                         LET nothing = LoadRGB4(Screen+44, Palette, PaletteColorCount)
  41.                         CALL PokeL(NewWindowStructure1+30,Screen)
  42.                 END IF
  43.  
  44. REM  Open the window
  45.                 LET Window = OpenWindow(NewWindowStructure1)
  46.                 IF MenuList1<>0 THEN  !  attach the Menu if present
  47.                         LET success = SetMenuStrip(Window,MenuList1)
  48.                 END IF
  49.  
  50. REM  Draw the various goodies if they are there
  51.                 LET rp = PeekL(Window+50)  !  get the RastPort address
  52.                 IF BorderList1<>0 THEN
  53.                         LET nothing = DrawBorder(rp,BorderList1,0,0)
  54.                 END IF
  55.                 IF ImageList1<>0 THEN
  56.                         LET nothing = DrawImage(rp,ImageList1,0,0)
  57.                 END IF
  58.                 IF ITextList1<>0 THEN
  59.                         LET nothing = PrintIText(rp,ITextList1,0,0)
  60.                 END IF
  61.  
  62. REM  Now start the input-event loop
  63.                 LET up = PeekL(Window+86)  !  get the UserPort address
  64.                 DO
  65.                         LET nothing = WaitPort(up)  !  wait for an IDCMP message
  66.                         LET message = GetMsg(up)  !  get the message
  67.                         LET class = PeekL(message+20)  !  get the class of the message
  68.                         LET menunum = PeekW(message+24)  !  get the message code for menu processing
  69.                         LET address = PeekL(message+28)  !  if a Gadget, get its address
  70.                         LET nothing = ReplyMsg(message) !  Reply the message
  71.  
  72. REM  Comment or remove the next 2 IF sections if no event-handler is used
  73.                         IF class=256 THEN
  74.                                 LET address = ItemAddress(MenuList1,menunum)
  75.                                 CALL HandleEvent(address)
  76.                         END IF
  77.                         IF class=32 or class=64 THEN
  78.                                 CALL HandleEvent(address)
  79.                         END IF
  80.  
  81.                 LOOP UNTIL class=512  !  terminate at CLOSEWINDOW event
  82.  
  83. REM  Do all deinitialization
  84.                 LET nothing = ClearMenuStrip(Window)  !  clear any menu
  85.                 LET nothing = CloseWindow(Window)  !  close the window
  86.                 IF Screen<>0 THEN  !  close the screen if open
  87.                         LET nothing = CloseScreen(Screen)
  88.                 END IF
  89.  
  90.                 LET nothing = FreeRemember(PW2RememberPtr,-1)  !  free all memory used
  91.  
  92.         END IF
  93.  
  94. REM  This is the only event handler routine required by the example files
  95. SUB quit(object)
  96.         LET class = 512  !  simulate a CLOSEWINDOW event to terminate loop
  97. END SUB
  98.  
  99.